package com.yd.app.mapper;

import com.yd.app.mapper.provider.AgreementProvider;
import com.yd.domain.business.Agreement;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 描述性文件
 * Created by zg on 2018/3/9.
 */
@Repository
public interface AgreementMapper {

    /**
     * 添加协议
     * @param agreement
     */
    @Insert("insert into business_agreement  (id,title,des,createTime,type) values  (#{agreement.id},#{agreement.title},#{agreement.des},#{agreement.createTime},#{agreement.type})")
    void addAgreement(@Param("agreement") Agreement agreement);
    /**
     * 修改协议
     * @param agreement
     */
    @Update("update business_agreement set des=#{agreement.des} where id=#{agreement.id}")
    void updateAgreement(@Param("agreement")Agreement agreement);
    /**
     * 删除协议
     * @param id
     */
    @Delete("delete from business_agreement where id=#{id}")
    void deleteAgreementById(@Param("id") String id);
    /**
     * 根据条件分页查询
     * @param agreement
     * @param startRow
     * @param pageSize
     * @return
     */
    @SelectProvider(method = "searchAgreementList", type = AgreementProvider.class)
    List<Agreement> getAgreementList(@Param("agreement")Agreement agreement,@Param("startRow") int startRow, @Param("pageSize") int pageSize);
    /**
     * 根据条件分页查询
     * @param agreement
     * @return
     */
    @SelectProvider(method = "getAgreementListCount", type = AgreementProvider.class)
    int getAgreementListCount(@Param("agreement")Agreement agreement);
    /**
     * @Author: zy
     * @Desc: 查看协议
     * @Date:  2018/3/15
     * @Param
     */
    @Select("select b.*,d.title as typeName from business_agreement b left join sys_dic d on b.type=d.`code` and d.type='agreeType' where b.type=#{xyType}")
    Agreement getXyByType(@Param("xyType") String xyType);
    /**
     * 获取全部协议数据
     * @return
     */
    @Select("select * from business_agreement  ")
    List<Agreement> getAgreementListAll();
    /**
     * 获取协议详情
     * @param id
     * @return
     */
    @Select("select * from business_agreement where id=#{id} ")
    Agreement getAgreementDetail(@Param("id") String id);
}
